package com.andy.note.boot.config.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

import lombok.extern.slf4j.Slf4j;

/**
 * 
 * 
 *
 * @author Andy<908119428@qq.com>
 * @version $Revision: 1.1 $ $Date: 2021年1月28日 上午8:42:30 $
 */
@Component
@Aspect
@Slf4j
public class TestAop {

    @Before("execution(* com.andy.note.boot.controller.aop..*.*  (..))")
    public void before() {
        log.info("test aop before!!!");
    }
    
    @Around("execution(* com.andy.note.boot.controller.aop..*.*  (..))")
    public Object around(ProceedingJoinPoint pjp) throws Throwable{
        log.info("[Aspect1] around advise 1");
        String proceed = (String)pjp.proceed();
        log.info("[Aspect1] around advise2");
        if(proceed.equals("bad")) return "good";
        return proceed;
    }
    
    
}
